class data_collector:
    def __init__(self, done_proc, request):
        self.done_proc = done_proc
        self.request = request
        self.old_terminator = None
        self.data = ""

    def set_terminator(self, terminator):
        # print "[Terminators]: Old, New: " + str(self.request.channel.get_terminator()) + ", " + str(terminator)
        self.old_terminator = self.request.channel.get_terminator()
        self.request.channel.set_terminator(terminator)

    def collect_incoming_data (self, data):
        self.data += data
        # lenData = len(self.data)
        # if lenData >= self.length:
        # self.data = self.data[0:self.length]

    def found_terminator(self):
        # Here, we make the actual request to the dispatcher
        self.request.pymq_payload = self.data
        self.data = ""
        self.set_terminator(self.old_terminator)
        self.request.channel.current_request = None
        self.done_proc(self.request)
        # self.request["X-MessageID"] = "1"; self.request.done()
